﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Kooboo.Commerce.AddIn;
using Kooboo.IoC;


namespace Kooboo.Commerce
{
    public static class IPaymentAction
    {
        public static IPaymentMethod FindMethod(this IPayment payment)
        {
            return ObjectContainer.CreateInstances<IPaymentMethod>()
                .Where(i =>i.Name == payment.MethodName)
                .FirstOrDefault();
        }

        public static void CheckMethod(this IPayment payment)
        {
            var method = payment.FindMethod();
            if ((method is IDirectPaymentMethod) == false)
            {
                payment.IsRedirect = true;
            }
        }

    }
}
